#include<func.h>
typedef struct{
    pthread_mutex_t mutex;
    pthread_cond_t cond;
}data_t;
void * threadfunc(void *p)
{
    data_t* d=(data_t *)p;
    pthread_mutex_lock(&d->mutex);
    pthread_cond_wait(&d->cond,&d->mutex);
    pthread_mutex_unlock(&d->mutex);
    printf("I am child wake up\n");
    pthread_exit(NULL);
}
int main()
{
    pthread_t pthid;
    data_t d;
    int ret=pthread_mutex_init(&d.mutex,NULL);
    THREAD_ERR_CHECK(ret,"pthread_mutex_init");
    ret=pthread_cond_init(&d.cond,NULL);
    THREAD_ERR_CHECK(ret,"pthread_cond_init");
    ret=pthread_create(&pthid,NULL,threadfunc,&d);
    THREAD_ERR_CHECK(ret,"pthread_create");
    sleep(1);
    ret=pthread_cond_signal(&d.cond);
    THREAD_ERR_CHECK(ret,"pthread_cond_wait");
    ret=pthread_join(pthid,NULL);
    THREAD_ERR_CHECK(ret,"pthread_join");
    printf("I am main thread\n");
    return 0;

}